<template>
    <view class="content">
        <view class="wrapper text-noraml">
            <!-- <view class="item">
                <view>库区名称</view>
                <view class="item-r">
                    <input type="text" placeholder="请选择" class="inp" disabled>
                    <u-icon name="arrow-down-fill" color="#a7a7a7" size="28" class="u-m-l-15"></u-icon>
                </view>
            </view>
            <view class="item">
                <view>仓位名称</view>
                <view class="item-r">
                    <input type="text" placeholder="请选择" class="inp" disabled>
                    <u-icon name="arrow-down-fill" color="#a7a7a7" size="28" class="u-m-l-15"></u-icon>
                </view>
            </view> -->
            <view class="item">
                <view>托盘</view>
                <view class="item-r">
                    <input type="text" v-model="name" placeholder="请输入" class="inp">
                </view>
            </view>
        </view>
        
        <view class="wrapper text-noraml">
            <view class="item">
                <view>是否启用</view>
                <u-switch v-model="checked"></u-switch>
            </view>
        </view>
        
        <view class="btn-square u-m-30" @click="$noMultipleClicks(doSubmit)">确认添加</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                noClick: true,//连点
                checked: true,
                name: '',
            };
        },
        onLoad() {
            
        },
        methods: {
            change(status) {
                console.log(status);
                this.checked = status
            },
            
            doSubmit() {
                if (!this.name) {
                    this.$toast('请输入托盘名称');
                    return
                }
                
                this.$ajax('inventorys/add_tray', {
                    userToken: this.$getSync('userToken'),
                    name: this.name,
                    status: this.checked == true ? 1 : 0,
                }).then(ret => {
                	if (ret.status == 0) {
                        this.$toast('提交成功');
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.message);
                	}
                });
            },
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #f5f5f5 !important;
    }
    .wrapper{
        padding: 0 30rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin: 30rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        border-bottom: 2rpx solid #e6e6e6;
    }
    .item:last-child{
        border-bottom: none;
    }
    .item-r{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
        text-align: right;
        padding-left: 20rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .inp{
        flex: 1;
    }
    

</style>
